package fudan.se.project.repository.projection;

import fudan.se.project.domain.message.Invitation;
import fudan.se.project.repository.projection.summary.UserSummary;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

public class InvitationProjection {


    private final Invitation invitation;


    private InvitationProjection(Invitation invitation) {
        this.invitation = invitation;
    }


    public long getId() {
        return invitation.getId();
    }

    public ConferenceProjection getConference() {
        return ConferenceProjection.project(invitation.getConference());
    }

    public String getState() {
        return invitation.getState().toString();
    }

    public UserSummary getSender() {
        return new UserSummary(invitation.getSender());
    }

    public UserSummary getReceiver() {
        return new UserSummary(invitation.getReceiver());
    }

    public Date getDateCreated() {
        return invitation.getDateCreated();
    }

    public static InvitationProjection project(Invitation invitation) {
        return new InvitationProjection(invitation);
    }

    public static List<InvitationProjection> project(Collection<Invitation> invitations) {
        ArrayList<InvitationProjection> arrayList = new ArrayList<>(invitations.size());
        for (Invitation value : invitations) {
            arrayList.add(project(value));
        }
        return arrayList;
    }
}
